// home模块的仓库

import { reqCateGoryList } from '@/api';

const state = {
    categoryList: []
}
const mutations = {
    setCategoryList(state, categoryList) {
        state.categoryList = categoryList
    }
}

const actions = {
    async goodCategoryList({ commit }) {
        // 发起请求
        console.log('发起请求');

        const res = await reqCateGoryList() // 等待请求结果
        console.log("商品分类：", res);

        if(res.code == 200){
            commit('setCategoryList', res.data); // 通过 Action 传递的载荷来修改状态
        }else{
            console.error('请求失败')
        }

        
    }
}
const getter = {}

export default {
    state,
    mutations,
    actions,
    getter
}